<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>推荐好友</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/api.js"></script>
    <script type="text/javascript" src="./script/aui-sharebox.js" ></script>
    <script type="text/javascript" src="./script/aui-tab.js" ></script>
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <script type="text/javascript" src="./script/aui-slide.js"></script>
    <script type="text/javascript">
        function closeWin(){
            api.closeWin({
            });
        };
    </script>
</head>
<body>
    <style>
        body{background:#f9f7e8; height:auto;}
    </style>
</body>
<script type="text/javascript">

    apiready = function()
    {
        var sharebox = new auiSharebox();
        openSharebox(sharebox);

        var h = api.winHeight;

        api.openFrame({
            name: 'closeShare',
            url: './roulettedraw3.html',
            rect: {
                x: 0,
                y: h-50,
                w: 'auto',
                h: 50
            },
            pageParam: {
                name: 'test'
            },
            bounces: false,
            bgColor: 'rgba(0,0,0,0)',
            vScrollBarEnabled: false,
            hScrollBarEnabled: false
        });

    }

    function openSharebox(sharebox)
    {
        sharebox.init({
            buttons:[{
                image:'./image/share/wx.png',
                text:'微信',
                value:'wx'//可选
            },{
                image:'./image/share/wx-circle.png',
                text:'朋友圈',
                value:'wx-circle'
            },
            ],
            col:4,
            cancelTitle:'关闭'
        },function(ret){
            if(ret){
              // alert(JSON.stringify(ret));
                // 对应按键走相应平台分享
                switch(ret.buttonIndex){
                    case 1:
                    wxShare();
                    break;
                    case 2:
                    friendCircleShare();
                    break;
                    case 3:
                    qqShare();
                    break;
                    case 4:
                    qqQzoneShare();
                    break;
                    case 5:
                    weiboShare();
                    break;
                    default:
                }
            }
        })

    };

    // 微信会话分享
    function wxShare()
    {
        var id = $api.getStorage('userid');
        var wx = api.require('wx');
        wx.shareWebpage({
         apiKey: 'wxdb1aaa8f4affc0c2',
         scene: 'session',
         title: '每日签到领大奖!!',
         description: '金可贷邀您一起领大奖!',
         thumb: 'widget://wgt/qiandao.jpg',
         contentUrl: 'http://www.big-wealth.com/thinkphp/public/index.php/signin/signin/app_index?id='
     }, function(ret, err)
     {
       if (ret.status)
       {
         api.ajax({
           url: 'http://www.big-wealth.com/thinkphp/public/index.php/signin/signin/wxshare?id='+id,
           method: 'post',
           data:
           {
             values: {},
           },
        },function(ret, err)
        {
          if(ret)
          {
            api.execScript({name: 'lphd',script: 'closeShare();'});
          }
          else
          {
            api.execScript({name: 'lphd',script: 'closeShare();'});
          }
        });
      }
      else
      {
        alert(err.code);
      }});
    };

    // 微信朋友圈分享
    function friendCircleShare()
    {
        var wx = api.require('wx');
        wx.shareWebpage({
            apiKey: 'wxdb1aaa8f4affc0c2',
            scene: 'timeline',
            title: '每日签到领大奖!!',
            description: '金可贷邀您一起领大奖!',
            thumb: 'widget://wgt/qiandao.jpg',
            contentUrl: 'http://www.big-wealth.com/thinkphp/public/index.php/signin/signin/app_index?id='
        }, function(ret, err)
        {
          if (ret.status)
          {
            api.ajax({
              url: 'http://www.big-wealth.com/thinkphp/public/index.php/signin/signin/wxshare?id='+id,
              method: 'post',
              data:
              {
                values: {},
              },
           },function(ret, err)
           {
             if(ret)
             {
               api.execScript({name: 'lphd',script: 'closeShare();'});
             }
             else
             {
               api.execScript({name: 'lphd',script: 'closeShare();'});
             }
           });
         }
         else
         {
           alert(err.code);
         }});
    };

    // qq会话分享
    function qqShare(){
        var qq = api.require('qq');
        qq.shareNews({
            type:'QFriend',
            url: 'http://www.baidu.com',
            title: '赚钱啦!!',
            description: '金可贷邀您一起赚大钱!',
            imgUrl: 'widget://wgt/qiandao.jpg'
        });
    };

    // qq空间分享
    function qqQzoneShare(){

        var qq = api.require('qq');
        qq.shareNews({
            type:'QZone',
            url: 'http://www.baidu.com',
            title: '赚钱啦!!',
            description: '金可贷邀您一起赚大钱!',
            imgUrl: 'https://gss3.bdstatic.com/-Po3dSag_xI4khGkpoWK1HF6hhy/baike/c0%3Dbaike180%2C5%2C5%2C180%2C60/sign=99a974ea81d4b31ce4319ce9e6bf4c1a/3c6d55fbb2fb4316be6615d32aa4462309f7d31a.jpg'
        });
    };

    // 微博分享
    function weiboShare(){

        var weibo = api.require('weibo');
        weibo.shareWebPage({
            text: '金可贷邀您一起赚大钱!',
            title: '赚钱啦!!',
            description: '金可贷金融平台今日上线',
            thumb: 'widget://wgt/qiandao.jpg',
            contentUrl: 'http://www.baidu.com'
        }, function(ret, err) {
            if (ret.status) {
                alert('分享成功');
            }
        });
    };

</script>
</html>
